import React from 'react'
import {  Switch, Route, Redirect  } from 'react-router-dom';
import "./RouterView.less"
export default function RouterView(props) {
  const { router } = props;
  // console.log(router,123);
  
  return (
    <div className='routerView'>
        <Switch>
          {
            router.map((item:any,index:any) => {
              if(item.from){
                return <Redirect key={index} from={item.from} to={item.to}/>
              }
           
              return <Route key={index} path={item.path} render={(router)=>{
                let Com = item.component;
                return <Com router={item.children} {...router}></Com>
              }}/>
           
            })
          }
        </Switch>
    </div>
  )
}